home *** CD-ROM | disk | FTP | other *** search
/ Nebula 2 / Nebula Two.iso / SourceCode / MiscKit1.7.1 / MiscKit / Headers / misckit / MiscString.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-06  |  24.4 KB  |  565 lines

  1. //
  2. //    MiscString.h -- a generic class to simplify manipulation of (char *)'s
  3. //        Written by Don Yacktman Copyright (c) 1993, 1994 by Don Yacktman.
  4. //                Version 1.95.  All rights reserved.
  5. //        This notice may not be removed from this source code.
  6. //
  7. //    This object is included in the MiscKit by permission from the author
  8. //    and its use is governed by the MiscKit license, found in the file
  9. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  10. //    for a list of all applicable permissions and restrictions.
  11. //    
  12.  
  13. #import <appkit/appkit.h>
  14.  
  15. #import <misckit/MiscProtocols.h>
  16.  
  17. #ifndef _MISCSTRING_H
  18. #define _MISCSTRING_H
  19.  
  20. // special constants for -extractPart... methods
  21. #define MISC_STRING_LAST -1
  22. #define MISC_STRING_FIRST 0
  23.  
  24. // character types...they can be OR'ed together...
  25. #define MISC_UPPER     1
  26. #define MISC_LOWER     2
  27. #define MISC_DIGIT     4
  28. #define MISC_XDIGIT    8
  29. #define MISC_PUNCT    16
  30. #define MISC_ASCII    32
  31. #define MISC_CNTRL    64
  32. #define MISC_PRINT   128
  33. #define MISC_SPACE   256
  34. #define MISC_GRAPH   512
  35.  
  36. /* A couple of obvious combinations */
  37. #define MISC_ALPHA (MISC_UPPER|MISC_LOWER)
  38. #define MISC_ALNUM (MISC_ALPHA|MISC_DIGIT)
  39.  
  40.  
  41. char *MiscBuildStringFromFormatV(const char *formatStr, va_list param_list);
  42.  
  43. // Note that the NXTransport protocol is handled by the NEXTSTEP category.
  44. @interface MiscString:Object
  45. {
  46.      char *buffer;
  47.      NXStringOrderTable *orderTable;
  48.      int length, _length;    // length is string length, _length is buffer size
  49. }
  50.  
  51. + initialize;
  52. + new;
  53. + newWithString:(const char *)aString;
  54. - new;
  55. - init;
  56. - initCapacity:(int)capacity;
  57. - initCapacity:(int)capacity fromZone:(NXZone *)zone;
  58. - initString:(const char *)aString;
  59. - initFromFormat:(const char *)formatStr, ...;
  60. - allocateBuffer:(int)size;
  61. - allocateBuffer:(int)size fromZone:(NXZone *)zone;
  62. - copyFromZone:(NXZone *)zone;
  63. - (char *)getCopyInto:(char *)buf;
  64. - freeString;
  65. - free;
  66. - (BOOL)emptyString;
  67. - (char)charAt:(int)index;
  68. - (int)numOfChar:(char)aChar caseSensitive:(BOOL)sense;
  69. - (int)numOfChar:(char)aChar;
  70. - (int)numOfChars:(const char *)aString caseSensitive:(BOOL)sense;
  71. - (int)numOfChars:(const char *)aString;
  72. - (int)length;
  73. - (unsigned)capacity;
  74. - setCapacity:(unsigned)newCapacity;
  75. - (size_t)recalcLength;
  76. - fixStringLength;
  77. - fixStringLengthAt:(unsigned)index;
  78. - setStringOrderTable:(NXStringOrderTable *)table;
  79. - (NXStringOrderTable *)stringOrderTable;
  80. - (const char *)stringValue;
  81. - (NXAtom)uniqueStringValue;
  82. - (const char *)stringValueAndFree;
  83. - (int)intValue;
  84. - (float)floatValue;
  85. - (double)doubleValue;
  86.  
  87. @end
  88.  
  89. @interface MiscString(Comparing) <MiscCompare, MiscEndCompare>
  90.  
  91. - (BOOL)isEqual:anObject;
  92. - (unsigned int)hash;
  93. - (int)cmp:(const char *)aString n:(int)n;
  94. - (int)compareTo:sender n:(int)n caseSensitive:(BOOL)sense;
  95. - (int)casecmp:(const char *)aString n:(int)n;
  96. - (int)endcmp:(const char *)aString n:(int)n;
  97. - (int)endcasecmp:(const char *)aString n:(int)n;
  98. - (int)endCompareTo:(id)sender n:(int)n caseSensitive:(BOOL)sense;
  99.  
  100. #ifndef _HEADER_VIEWER_  /* convenience methods */
  101. - (int)cmp:(const char *)aString;
  102. - (int)casecmp:(const char *)aString;
  103. - (int)endcmp:(const char *)aString;
  104. - (int)endcasecmp:(const char *)aString;
  105. - (int)compareTo:sender;
  106. - (int)compareTo:sender n:(int)n;
  107. - (int)compareTo:sender caseSensitive:(BOOL)sense;
  108. - (int)endCompareTo:(id)sender;
  109. - (int)endCompareTo:(id)sender caseSensitive:(BOOL)sense;
  110. - (int)endCompareTo:(id)sender n:(int)n;
  111. #endif
  112.  
  113. @end
  114.  
  115. @interface MiscString(Debugging)
  116.  
  117. - buildInstanceImageIn:(char *)buf;
  118. - printForDebugger:(NXStream *)stream;
  119. - printToStdErr:(const char *)label;
  120.  
  121. @end
  122.  
  123. @interface MiscString(Fields)
  124.  
  125. - subStringRight:subString;
  126. - subStringLeft:subString;
  127. - left:(int)count fromZone:(NXZone *)zone;
  128. - right:(int)count fromZone:(NXZone *)zone;
  129. - midFrom:(int)start to:(int)end fromZone:(NXZone *)zone;
  130. - midFrom:(int)start length:(int)len fromZone:(NXZone *)zone;
  131. - extractPart:(int)n useAsDelimiter:(char)c caseSensitive:(BOOL)sense
  132.         fromZone:(NXZone *)zone;
  133. - wordNum:(int) num fromZone:(NXZone *)zone;
  134. - (int)numWords;
  135. - tokenize:(const char *)breakChars into:aList;
  136.  
  137. #ifndef _HEADER_VIEWER_  /* convenience methods */
  138. - extractPart:(int)n useAsDelimiter:(char)c caseSensitive:(BOOL)sense;
  139. - extractPart:(int)n useAsDelimiter:(char)c fromZone:(NXZone *)zone;
  140. - extractPart:(int)n useAsDelimiter:(char)c;
  141. - wordNum:(int) num;
  142. - left:(int)count;
  143. - right:(int)count;
  144. - midFrom:(int)start to:(int)end;
  145. - midFrom:(int)start length:(int)len;
  146. #endif
  147.  
  148. @end
  149.  
  150. @interface MiscString(Insertion)
  151.  
  152. - cat:(const char *)aString n:(int)n fromZone:(NXZone *)zone;
  153. - concatenate:sender n:(int)n fromZone:(NXZone *)zone;
  154. - insert:(const char *)aString at:(int)index;
  155. - insertString:(id)sender at:(int)index;
  156. - insertChar:(char)aChar at:(int)index;
  157. - catStrings:  ( const char *) strings,  ...;
  158. - concatenateStrings:(id)strings,  ...;
  159. - insert:(const char *)aString;
  160. - insertString:aString;
  161. - addChar:(char)aChar;
  162. - insertFromFormat:(const char *)format, ...;
  163. - insertAt:(int)index fromFormat:(const char *)format, ...;
  164. - catFromFormat:(const char *)format, ...;
  165.  
  166. #ifndef _HEADER_VIEWER_  /* convenience methods */
  167. - cat:(const char *)aString;
  168. - cat:(const char *)aString n:(int)n;
  169. - cat:(const char *)aString fromZone:(NXZone *)zone;
  170. - concatenate:sender;
  171. - concatenate:sender n:(int)n;
  172. - concatenate:sender fromZone:(NXZone *)zone;
  173. - insertChar:(char)aChar;
  174. #endif
  175.  
  176. @end
  177.  
  178. @interface MiscString(Modification)
  179.  
  180. - setStringValue:(const char *)aString;
  181. - setStringValue:(const char *)aString n:(int)n fromZone:(NXZone *)zone;
  182. - setFromFormat:(const char *)formatStr, ...;
  183. - setIntValue:(int)val;
  184. - setFloatValue:(float)val;
  185. - setDoubleValue:(double)val;
  186. - sprintf:(const char *)formatStr, ...;
  187. - takeStringValueFrom:sender;
  188. - takeStringValueFrom:sender fromZone:(NXZone *)zone;
  189. - takeIntValueFrom:sender;
  190. - takeFloatValueFrom:sender;
  191. - takeDoubleValueFrom:sender;
  192. - trimLeadSpaces;
  193. - trimTailSpaces;
  194. - trimSpaces;
  195. - trimLeadWhiteSpaces;
  196. - trimTailWhiteSpaces;
  197. - trimWhiteSpaces;
  198. - squashSpaces;
  199. - reverse;
  200. - toUpper;
  201. - toLower;
  202. - invertCases;
  203. - capitalizeEachWord;
  204. - removeFrom:(int)index length:(int)len;
  205. - removeFrom:(int)start to:(int)end;
  206. - (int)gets;
  207. - (int)fgets:(FILE *)fd keepNewline:(BOOL)keepit;
  208. - (int)streamGets:(NXStream *)stream keepNewline:(BOOL)keepit;
  209. - padToLength:(int)len withChar:(char)aChar;
  210. - padFrontToLength:(int)len withChar:(char)aChar;
  211.  
  212. #ifndef _HEADER_VIEWER_  /* convenience methods */
  213. - setStringValue:(const char *)aString fromZone:(NXZone *)zone;
  214. - setStringValue:(const char *)aString n:(int)n;
  215. - (int)fgets:(FILE *)fd;
  216. - (int)streamGets:(NXStream *)stream;
  217. #endif
  218.  
  219. @end
  220.  
  221. @interface MiscString(NEXTSTEP) <NXTransport>
  222.  
  223. - read:(NXTypedStream *)stream;
  224. - write:(NXTypedStream *)stream;
  225. - (BOOL)isRTFText;
  226. - (MiscString *)plainTextForRTF;
  227. - (const char *)getInspectorClassName;
  228. - (NXImage *)getIBImage;
  229. - writeToStream:(NXStream *)aStream;
  230.  
  231. @end
  232.  
  233. #import <misckit/MiscStringPatterns.h>
  234. #import <misckit/MiscStringRegex.h>
  235. #import <misckit/MiscString_ExtendedParsing.h>
  236. #import <misckit/MiscStringCompatability.h>
  237.  
  238. @interface MiscString(Replacing)
  239.  
  240. - replaceFrom:(int)start length:(int)len with:(const char *)aString;
  241. - replaceFrom:(int)start to:(int)end with:(const char *)aString;
  242. - replaceFrom:(int)start length:(int)len withString:(id)sender;
  243. - replaceFrom:(int)start to:(int)end withString:(id)sender;
  244. - replace:(const char *)subString with:(const char *)newString;
  245. - replace:(const char *)subString withString:(id)sender;
  246. - replaceCharAt:(int)index withChar:(char)aChar;
  247. - replaceFrom:(int)start length:(int)len withChar:(char)aChar;
  248. - replaceFrom:(int)start to:(int)end withChar:(char)aChar;
  249.  
  250. - replaceEveryOccurrenceOfChars:(const char *)aString with:(const char *)replaceString caseSensitive:(BOOL)sense;
  251. - replaceEveryOccurrenceOfChars:(const char *)aString withChar:(char)replaceChar caseSensitive:(BOOL)sense;
  252. - replaceEveryOccurrenceOfChars:(const char *)aString withString:(id)sender caseSensitive:(BOOL)sense;
  253. - replaceEveryOccurrenceOfChar:(char)aChar with:(const char *)aString caseSensitive:(BOOL)sense;
  254. - replaceEveryOccurrenceOfChar:(char)aChar withString:(id)sender caseSensitive:(BOOL)sense;
  255. - replaceEveryOccurrenceOfChar:(char)aChar withChar:(char)replaceChar caseSensitive:(BOOL)sense;
  256.  
  257. - replaceType:(int)type with:(const char *)str occurrenceNum:(int)n;
  258. - replaceType:(int)type withChar:(char)aChar occurrenceNum:(int)n;
  259. - replaceType:(int)type withString:(id)sender occurrenceNum:(int)n;
  260. - replaceEveryOccurrenceOfType:(int)type with:(const char *)str;
  261. - replaceEveryOccurrenceOfType:(int)type withChar:(char)aChar;
  262. - replaceEveryOccurrenceOfType:(int)type withString:(id)sender;
  263.  
  264. - (int)replaceEveryOccurrenceOf:(const char *)str with:(const char *)repl caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  265. - (int)replaceEveryOccurrenceOf:(const char *)str withChar:(char)aChar caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  266. - (int)replaceEveryOccurrenceOf:(const char *)str withString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  267. - (int)replaceEveryOccurrenceOfString:(id)sender with:(const char *)repl caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  268. - (int)replaceEveryOccurrenceOfString:(id)sender withChar:(char)aChar caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  269. - (int)replaceEveryOccurrenceOfString:(id)sender withString:(id)repl caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  270. - replace:(const char *)str with:(const char *)repl occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  271. - replace:(const char *)str withChar:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  272. - replace:(const char *)str withString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  273. - replaceString:(id)sender with:(const char *)repl occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  274. - replaceString:(id)sender withChar:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  275. - replaceString:(id)sender withString:(id)repl occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  276.  
  277. #ifndef _HEADER_VIEWER_  /* convenience methods */
  278. - replaceEveryOccurrenceOfChars:(const char *)aString with:(const char *)replaceString;
  279. - replaceEveryOccurrenceOfChars:(const char *)aString withChar:(char)replaceChar;
  280. - replaceEveryOccurrenceOfChars:(const char *)aString withString:(id)sender;
  281. - replaceEveryOccurrenceOfChar:(char)aChar with:(const char *)aString;
  282. - replaceEveryOccurrenceOfChar:(char)aChar withString:(id)sender;
  283. - replaceEveryOccurrenceOfChar:(char)aChar withChar:(char)replaceChar;
  284.  
  285. - replaceType:(int)type with:(const char *)str;
  286. - replaceType:(int)type withChar:(char)aChar;
  287. - replaceType:(int)type withString:(id)sender;
  288.  
  289. - (int)replaceEveryOccurrenceOf:(const char *)str with:(const char *)repl;
  290. - (int)replaceEveryOccurrenceOf:(const char *)str with:(const char *)repl caseSensitive:(BOOL)sense;
  291. - (int)replaceEveryOccurrenceOf:(const char *)str with:(const char *)repl overlap:(BOOL)overlap;
  292.  
  293. - (int)replaceEveryOccurrenceOf:(const char *)str withChar:(char)aChar;
  294. - (int)replaceEveryOccurrenceOf:(const char *)str withChar:(char)aChar caseSensitive:(BOOL)sense;
  295. - (int)replaceEveryOccurrenceOf:(const char *)str withChar:(char)aChar overlap:(BOOL)overlap;
  296.  
  297. - (int)replaceEveryOccurrenceOf:(const char *)str withString:(id)sender;
  298. - (int)replaceEveryOccurrenceOf:(const char *)str withString:(id)sender caseSensitive:(BOOL)sense;
  299. - (int)replaceEveryOccurrenceOf:(const char *)str withString:(id)sender overlap:(BOOL)overlap;
  300.  
  301. - (int)replaceEveryOccurrenceOfString:(id)sender with:(const char *)repl;
  302. - (int)replaceEveryOccurrenceOfString:(id)sender with:(const char *)repl caseSensitive:(BOOL)sense;
  303. - (int)replaceEveryOccurrenceOfString:(id)sender with:(const char *)repl overlap:(BOOL)overlap;
  304.  
  305. - (int)replaceEveryOccurrenceOfString:(id)sender withChar:(char)aChar;
  306. - (int)replaceEveryOccurrenceOfString:(id)sender withChar:(char)aChar caseSensitive:(BOOL)sense;
  307. - (int)replaceEveryOccurrenceOfString:(id)sender withChar:(char)aChar overlap:(BOOL)overlap;
  308.  
  309. - (int)replaceEveryOccurrenceOfString:(id)sender withString:(id)repl;
  310. - (int)replaceEveryOccurrenceOfString:(id)sender withString:(id)repl caseSensitive:(BOOL)sense;
  311. - (int)replaceEveryOccurrenceOfString:(id)sender withString:(id)repl overlap:(BOOL)overlap;
  312.  
  313. - replace:(const char *)str with:(const char *)repl;
  314. - replace:(const char *)str with:(const char *)repl occurrenceNum:(int)n;
  315. - replace:(const char *)str with:(const char *)repl caseSensitive:(BOOL)sense;
  316. - replace:(const char *)str with:(const char *)repl occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  317. - replace:(const char *)str with:(const char *)repl overlap:(BOOL)overlap;
  318. - replace:(const char *)str with:(const char *)repl occurrenceNum:(int)n overlap:(BOOL)overlap;
  319. - replace:(const char *)str with:(const char *)repl caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  320.  
  321. - replace:(const char *)str withChar:(char)aChar;
  322. - replace:(const char *)str withChar:(char)aChar occurrenceNum:(int)n;
  323. - replace:(const char *)str withChar:(char)aChar caseSensitive:(BOOL)sense;
  324. - replace:(const char *)str withChar:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  325. - replace:(const char *)str withChar:(char)aChar overlap:(BOOL)overlap;
  326. - replace:(const char *)str withChar:(char)aChar occurrenceNum:(int)n overlap:(BOOL)overlap;
  327. - replace:(const char *)str withChar:(char)aChar caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  328.  
  329. - replace:(const char *)str withString:(id)sender;
  330. - replace:(const char *)str withString:(id)sender occurrenceNum:(int)n;
  331. - replace:(const char *)str withString:(id)sender caseSensitive:(BOOL)sense;
  332. - replace:(const char *)str withString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  333. - replace:(const char *)str withString:(id)sender overlap:(BOOL)overlap;
  334. - replace:(const char *)str withString:(id)sender occurrenceNum:(int)n overlap:(BOOL)overlap;
  335. - replace:(const char *)str withString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  336.  
  337. - replaceString:(id)sender with:(const char *)repl;
  338. - replaceString:(id)sender with:(const char *)repl occurrenceNum:(int)n;
  339. - replaceString:(id)sender with:(const char *)repl caseSensitive:(BOOL)sense;
  340. - replaceString:(id)sender with:(const char *)repl occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  341. - replaceString:(id)sender with:(const char *)repl overlap:(BOOL)overlap;
  342. - replaceString:(id)sender with:(const char *)repl occurrenceNum:(int)n overlap:(BOOL)overlap;
  343. - replaceString:(id)sender with:(const char *)repl caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  344.  
  345. - replaceString:(id)sender withChar:(char)aChar;
  346. - replaceString:(id)sender withChar:(char)aChar occurrenceNum:(int)n;
  347. - replaceString:(id)sender withChar:(char)aChar caseSensitive:(BOOL)sense;
  348. - replaceString:(id)sender withChar:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  349. - replaceString:(id)sender withChar:(char)aChar overlap:(BOOL)overlap;
  350. - replaceString:(id)sender withChar:(char)aChar occurrenceNum:(int)n overlap:(BOOL)overlap;
  351. - replaceString:(id)sender withChar:(char)aChar caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  352.  
  353. - replaceString:(id)sender withString:(id)repl;
  354. - replaceString:(id)sender withString:(id)repl occurrenceNum:(int)n;
  355. - replaceString:(id)sender withString:(id)repl caseSensitive:(BOOL)sense;
  356. - replaceString:(id)sender withString:(id)repl occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  357. - replaceString:(id)sender withString:(id)repl overlap:(BOOL)overlap;
  358. - replaceString:(id)sender withString:(id)repl occurrenceNum:(int)n overlap:(BOOL)overlap;
  359. - replaceString:(id)sender withString:(id)repl caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  360. #endif
  361.  
  362. @end
  363.  
  364. @interface MiscString(Searching)
  365.  
  366. - (int)spotOf:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  367. - (int)rspotOf:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  368. - (const char *)rindex:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  369. - (const char *)index:(char)aChar occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  370. - (int)spotOfChars:(const char *)aString occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  371. - (int)rspotOfChars:(const char *)aString occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  372. - (const char *)rindexOfChars:(const char *)aString occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  373. - (const char *)indexOfChars:(const char *)aString occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  374.  
  375. - (BOOL) hasType:(int)type;
  376. - (BOOL) isAllOfType:(int)type;
  377. - (int)spotOfType:(int)type occurrenceNum:(int)n;
  378. - (int)rspotOfType:(int)type occurrenceNum:(int)n;
  379.  
  380. - (int)spotOfStr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  381. - (int)rspotOfStr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  382. - (int)spotOfString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  383. - (int)rspotOfString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  384. - (const char *)strstr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  385. - (const char *)rstrstr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  386. - (const char *)strString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  387. - (const char *)rstrString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  388. - (int)numOfType:(int)type;
  389. - (int)numOf:(const char *)str caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  390. - (int)numOfString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  391.  
  392. #ifndef _HEADER_VIEWER_  /* convenience methods */
  393. - (int)spotOf:(char)aChar;
  394. - (int)spotOf:(char)aChar caseSensitive:(BOOL)sense;
  395. - (int)spotOf:(char)aChar occurrenceNum:(int)n;
  396. - (int)rspotOf:(char)aChar;
  397. - (int)rspotOf:(char)aChar caseSensitive:(BOOL)sense;
  398. - (int)rspotOf:(char)aChar occurrenceNum:(int)n;
  399.  
  400. - (const char *)rindex:(char)aChar;
  401. - (const char *)rindex:(char)aChar occurrenceNum:(int)n;
  402. - (const char *)rindex:(char)aChar caseSensitive:(BOOL)sense;
  403. - (const char *)index:(char)aChar;
  404. - (const char *)index:(char)aChar occurrenceNum:(int)n;
  405. - (const char *)index:(char)aChar caseSensitive:(BOOL)sense;
  406.  
  407. - (int)spotOfChars:(const char *)aString;
  408. - (int)spotOfChars:(const char *)aString caseSensitive:(BOOL)sense;
  409. - (int)spotOfChars:(const char *)aString occurrenceNum:(int)n;
  410. - (int)rspotOfChars:(const char *)aString;
  411. - (int)rspotOfChars:(const char *)aString caseSensitive:(BOOL)sense;
  412. - (int)rspotOfChars:(const char *)aString occurrenceNum:(int)n;
  413.  
  414. - (const char *)rindexOfChars:(const char *)aString;
  415. - (const char *)rindexOfChars:(const char *)aString caseSensitive:(BOOL)sense;
  416. - (const char *)rindexOfChars:(const char *)aString occurrenceNum:(int)n;
  417. - (const char *)indexOfChars:(const char *)aString;
  418. - (const char *)indexOfChars:(const char *)aString caseSensitive:(BOOL)sense;
  419. - (const char *)indexOfChars:(const char *)aString occurrenceNum:(int)n;
  420.  
  421. - (int)spotOfType:(int)type;
  422. - (int)rspotOfType:(int)type;
  423.  
  424. - (int)spotOfStr:(const char *)str;
  425. - (int)spotOfStr:(const char *)str occurrenceNum:(int)n;
  426. - (int)spotOfStr:(const char *)str caseSensitive:(BOOL)sense;
  427. - (int)spotOfStr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  428. - (int)spotOfStr:(const char *)str overlap:(BOOL)overlap;
  429. - (int)spotOfStr:(const char *)str occurrenceNum:(int)n overlap:(BOOL)overlap;
  430. - (int)spotOfStr:(const char *)str caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  431.  
  432. - (int)rspotOfStr:(const char *)str;
  433. - (int)rspotOfStr:(const char *)str occurrenceNum:(int)n;
  434. - (int)rspotOfStr:(const char *)str caseSensitive:(BOOL)sense;
  435. - (int)rspotOfStr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  436. - (int)rspotOfStr:(const char *)str overlap:(BOOL)overlap;
  437. - (int)rspotOfStr:(const char *)str occurrenceNum:(int)n overlap:(BOOL)overlap;
  438. - (int)rspotOfStr:(const char *)str caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  439.  
  440. - (int)spotOfString:(id)sender;
  441. - (int)spotOfString:(id)sender occurrenceNum:(int)n;
  442. - (int)spotOfString:(id)sender caseSensitive:(BOOL)sense;
  443. - (int)spotOfString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  444. - (int)spotOfString:(id)sender overlap:(BOOL)overlap;
  445. - (int)spotOfString:(id)sender occurrenceNum:(int)n overlap:(BOOL)overlap;
  446. - (int)spotOfString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  447.  
  448. - (int)rspotOfString:(id)sender;
  449. - (int)rspotOfString:(id)sender occurrenceNum:(int)n;
  450. - (int)rspotOfString:(id)sender caseSensitive:(BOOL)sense;
  451. - (int)rspotOfString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  452. - (int)rspotOfString:(id)sender overlap:(BOOL)overlap;
  453. - (int)rspotOfString:(id)sender occurrenceNum:(int)n overlap:(BOOL)overlap;
  454. - (int)rspotOfString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  455.  
  456. - (const char *)strstr:(const char *)str;
  457. - (const char *)strstr:(const char *)str occurrenceNum:(int)n;
  458. - (const char *)strstr:(const char *)str caseSensitive:(BOOL)sense;
  459. - (const char *)strstr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  460. - (const char *)strstr:(const char *)str overlap:(BOOL)overlap;
  461. - (const char *)strstr:(const char *)str occurrenceNum:(int)n overlap:(BOOL)overlap;
  462. - (const char *)strstr:(const char *)str caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  463.  
  464. - (const char *)rstrstr:(const char *)str;
  465. - (const char *)rstrstr:(const char *)str occurrenceNum:(int)n;
  466. - (const char *)rstrstr:(const char *)str caseSensitive:(BOOL)sense;
  467. - (const char *)rstrstr:(const char *)str occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  468. - (const char *)rstrstr:(const char *)str overlap:(BOOL)overlap;
  469. - (const char *)rstrstr:(const char *)str occurrenceNum:(int)n overlap:(BOOL)overlap;
  470. - (const char *)rstrstr:(const char *)str caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  471.  
  472. - (const char *)strString:(id)sender;
  473. - (const char *)strString:(id)sender occurrenceNum:(int)n;
  474. - (const char *)strString:(id)sender caseSensitive:(BOOL)sense;
  475. - (const char *)strString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  476. - (const char *)strString:(id)sender overlap:(BOOL)overlap;
  477. - (const char *)strString:(id)sender occurrenceNum:(int)n overlap:(BOOL)overlap;
  478. - (const char *)strString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  479.  
  480. - (const char *)rstrString:(id)sender;
  481. - (const char *)rstrString:(id)sender occurrenceNum:(int)n;
  482. - (const char *)rstrString:(id)sender caseSensitive:(BOOL)sense;
  483. - (const char *)rstrString:(id)sender occurrenceNum:(int)n caseSensitive:(BOOL)sense;
  484. - (const char *)rstrString:(id)sender overlap:(BOOL)overlap;
  485. - (const char *)rstrString:(id)sender occurrenceNum:(int)n overlap:(BOOL)overlap;
  486. - (const char *)rstrString:(id)sender caseSensitive:(BOOL)sense overlap:(BOOL)overlap;
  487.  
  488. - (int)numOf:(const char *)str;
  489. - (int)numOf:(const char *)str caseSensitive:(BOOL)sense;
  490. - (int)numOf:(const char *)str overlap:(BOOL)overlap;
  491.  
  492. - (int)numOfString:(id)sender;
  493. - (int)numOfString:(id)sender caseSensitive:(BOOL)sense;
  494. - (int)numOfString:(id)sender overlap:(BOOL)overlap;
  495. #endif
  496.  
  497. @end
  498.  
  499. @interface MiscString(Sybase)
  500.  
  501. - convertUnixWildcardsToSybase;
  502. - convertToCaseInsensitiveSearchString;
  503. - makeCaseInsensitiveSearchString;
  504.  
  505. @end
  506.  
  507. // These are legal arguments for the -isFileOfType: method...
  508. typedef enum _MiscFileType {
  509.     Misc_Socket           = S_IFSOCK,  // socket
  510.     Misc_Directory        = S_IFDIR,   // directory
  511.     Misc_PlainFile        = S_IFREG,   // regular (plain) file
  512.     Misc_SymbolicLink     = S_IFLNK,   // symbolic link
  513.     Misc_CharacterSpecial = S_IFCHR,   // character special
  514.     Misc_BlockSpecial     = S_IFBLK,   // block special
  515.     Misc_Fifo             = S_IFIFO    // fifo (Sun VFS)
  516. } MiscFileType;
  517.  
  518. @interface MiscString(Unix)
  519.  
  520. // all MiscStrings use a global separator for splitting up paths.
  521. // it's less overhead than making a UNIX subclass that stores these
  522. // for each and every path...and typically you would never need to
  523. // worry about changing these anyway...
  524. + setPathSeparator:(char)c;
  525. + setExtensionSeparator:(char)c;
  526. + (char)extensionSeparator;
  527. + (char)pathSeparator;
  528.  
  529. // passwords
  530. - encrypt:salt;
  531.  
  532. // parsing paths
  533. - fileName;
  534. - pathName;
  535. - fileExtension;
  536. - fileBasename;
  537. - fileNameFromZone:(NXZone *)zone;
  538. - pathNameFromZone:(NXZone *)zone;
  539. - fileExtensionFromZone:(NXZone *)zone;
  540. - fileBasenameFromZone:(NXZone *)zone;
  541. - addExtensionIfNeeded:(const char *)aString;
  542.  
  543. // manipulating paths
  544. - replaceHomeWithTilde;
  545. - replaceTildeWithHome;
  546.  
  547. // info about paths
  548. - (BOOL)isRelativePath;
  549. - (BOOL)isAbsolutePath;
  550. - (BOOL)doesExistInFileSystem;
  551. - (BOOL)isFileOfType:(MiscFileType)fileType;
  552. - (int)numberOfPathComponents;
  553. - pathComponentAt:(int)index;
  554. - setDirectory:(const char *)dir file:(const char *)file;
  555. - initDirectory:(const char *)dir file:(const char *)file;
  556.  
  557. - (int)system; // runs the system() function on the string
  558.  
  559. - loadFromFile:(const char *)fileName; // reads contents of file
  560.     // into the string
  561.  
  562. @end
  563.  
  564. #endif /* _MISCSTRING_H */
  565.